//
//  LKWorkOrderListDetailPictureCell.m
//  YLHelper
//
//  Created by she1323 on 2018/4/25.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKWorkOrderListDetailPictureCell.h"

@implementation LKWorkOrderListDetailPictureCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.pictureImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showBigPicture:)];
    [self.pictureImageView addGestureRecognizer:tap];
    // Initialization code
}

/**
 选中图片的点击手势
 
 @param tap 手势
 */
-(void)showBigPicture:(UITapGestureRecognizer *)tap{
    if (!self.pitureUrl) {
        return;
    }
    UIImageView *imageV = (UIImageView *)tap.view;
    NSMutableArray *pictre = [[NSMutableArray alloc] initWithArray:@[self.pitureUrl]];
    [self showWithTouchIntag:1 AndWithPicturesArray:pictre AndSorceImageView:imageV];
}

#pragma mark 图片浏览器使用案例 (image brower use case)

#pragma mark 方式一：使用数组配置数据源
- (void)showWithTouchIntag:(NSInteger )indexPath AndWithPicturesArray:(NSArray *)picturesArray AndSorceImageView:(UIImageView *)currentImageV{
    
    //创建图片浏览器（注意：更多功能请看 YBImageBrowser.h 文件或者 github readme）
    YBImageBrowser *browser = [YBImageBrowser new];
    browser.currentIndex = indexPath;
    
    //配置数据源（图片浏览器每一张图片对应一个 YBImageBrowserModel 实例）
    NSMutableArray *tempArr = [NSMutableArray array];
    [picturesArray enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        YBImageBrowserModel *model = [YBImageBrowserModel new];
        model.url = [NSURL URLWithString:obj];
        //        [model setImageWithFileName:obj fileType:@"png"];
        model.sourceImageView = currentImageV;
        [tempArr addObject:model];
    }];
    
    browser.dataArray = tempArr;
    
    //    YBImageBrowserFunctionModel *fm = [YBImageBrowserFunctionModel new];
    //    fm.name = @"分享";
    //    browser.fuctionDataArray = @[[YBImageBrowserFunctionModel functionModelForSavePictureToAlbum], fm];
    //展示
    [browser show];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end
